package com.demo.core.dao.impl;

import java.util.Map;

import com.demo.core.dao.RoleDao;
import com.demo.core.dao.impl.base.BaseCoreDaoSupport;
import com.demo.core.model.Role;
import com.demo.core.model.support.GeneralExecuteModel;

/**
 * 角色数据访问层实现类
 * 
 * @author ryuu.kk
 */
public class RoleDaoImpl extends BaseCoreDaoSupport<Role, Long> implements RoleDao {
	/**
	 * 角色空间 
	 */
	protected final static String ROLE_SPACE = "roleSpace.";
	/**
	 * 模型表名
	 */
	protected final static String TABLE_NAME = "T_CORE_ROLE";
	/**
	 * 模型表主键ID
	 */
	protected final static String TABLE_PK_NAME = "ID";

	@Override
	public int updateType(Role role, Map<String, Object> roleInfo) {
		cacheClear();
		roleInfo.put("role", role);
		return getSqlMapClientTemplate().update(ROLE_SPACE + "changeType", roleInfo);
	}

	@Override
	public int updateStatus(Role role, Map<String, Object> roleInfo) {
		cacheClear();
		roleInfo.put("role", role);
		return getSqlMapClientTemplate().update(ROLE_SPACE + "changeRoleStatus", roleInfo);
	}

	@Override
	public int updatePriority(Role role, Map<String, Object> roleInfo) {
		cacheClear();
		roleInfo.put("role", role);
		return getSqlMapClientTemplate().update(ROLE_SPACE + "changePriority", roleInfo);
	}

	@Override
	protected String nameSpace() {
		return ROLE_SPACE;
	}
	@Override
	protected void doInit(GeneralExecuteModel<Long> model) {
		model.setPk(TABLE_PK_NAME);
		model.setTable(TABLE_NAME);
	}
}
